home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5402 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: erich.triumf.ca!bennett
  2. From: bennett@erich.triumf.ca (P.Bennett)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Character String --> Integer
  5. Date: 7 Feb 1996 15:08 PST
  6. Organization: TRIUMF: Tri-University Meson Facility
  7. Distribution: world
  8. Message-ID: <7FEB199615084505@erich.triumf.ca>
  9. References: <4fb0ga$lsa@remus.rutgers.edu>
  10. NNTP-Posting-Host: ftp.triumf.ca
  11. News-Software: VAX/VMS VNEWS 1.50    
  12.  
  13. In article <4fb0ga$lsa@remus.rutgers.edu>, wempa@remus.rutgers.edu (Force Of Nature) writes...
  14. >Is there an easy way to convert a character string such as '2425' to the
  15. >integer 2425 ???  The only way I can think of is to pick off characters 
  16. >one at a time and use switch statements to determine the value (0-9) and
  17. >then multiply by the correct power of 10.  Is there an easier way to do
  18. >this ???????
  19.  
  20. Try the following functions:
  21.     sscanf()
  22.     atoi()
  23. (to convert an int to a string, use sprintf() )    
  24.  
  25. Peter Bennett VE7CEI                | Vessels shall be deemed to be in sight
  26. Internet: bennett@triumf.ca         | of one another only when one can be
  27. Packet: ve7cei@ve7kit.#vanc.bc.ca   | observed visually from the other
  28. TRIUMF, Vancouver, B.C., Canada     |                          ColRegs 3(k)
  29. GPS and NMEA info and programs: ftp://sundae.triumf.ca/pub/peter/index.html
  30.  
  31.